<?php

// @formatter:off
/**
 * @file login.php
 * @author Alejandro Dario Simi
 * @date $Date: 2014-05-04 01:33:52 +0000 (Sun, 04 May 2014) $
 *
 * $Id: login.php 111 2014-05-04 01:33:52Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/frontview/actions/content/user/login.php $
 */
// @formatter:on

class ActionControllerContentUserLogin extends WCActionController {
	//
	// Public methods.
	public function check() {
		$check = parent::check();

		if($check == WC_HTTPERROR_OK) {
			global $wcUser;
			global $wcProfile;

			if($check == WC_HTTPERROR_OK && $wcUser) {
				global $errno;
				global $error;

				$check = WC_HTTPERROR_BAD_REQUEST;
				$errno = $check;
				$error = "You're already logged in";
			}
			if($check == WC_HTTPERROR_OK && !$wcProfile->allowedTo(WC_PERM_USER_LOGIN)) {
				global $errno;
				global $error;

				$check = WC_HTTPERROR_FORBIDDEN;
				$errno = $check;
				$error = "You're not allowed to login";
			}
		}

		return $check;
	}
	//
	// Protected methods.
//	protected function subRun() {
//		$ok = true;
//
//		//
//		// Loading global pointers.
//		global $wcProfile;
//
//		$groups = array();
//		foreach(WCGroupsHolder::I()->items() as $group) {
//			if($wcProfile->grantedGroup($group) && is_readable($group->root)) {
//				$groups[$group->name] = $group;
//			}
//		}
//		ksort($groups);
//
//		$groupsAssigns = array();
//		foreach($groups as $group) {
//			$groupsAssigns[] = array(
//				"id" => $group->id,
//				"name" => $group->name
//			);
//		}
//		$this->_manager->groups = $groupsAssigns;
//
//		return $ok;
//	}
}

?>